<template>
    <div class="box">
        <header class="header">
            <van-nav-bar title="收获地址" left-arrow @click-left="$router.go(-1)" />
        </header>
        <div class="content">
            <van-address-list v-model="chosenAddressId" :list="store.addressList" @select="onSelect" />
        </div>
    </div>
</template>
<script>
import { useCounterStore } from '@/stores/counter'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { onMounted } from 'vue'
export default {
    setup() {
        const store = useCounterStore()
        const router = useRouter()
        const chosenAddressId = ref('1')
        const onSelect = (item) => {
            store.changeisChecked(item.id)
            router.back()
        }
        onMounted(() => {
            chosenAddressId.value = store.checkedAddress.id
        })
        return {
            store,
            router,
            chosenAddressId,
            onSelect
        }
    }
}
</script>